<div class="layui-fluid layui-anim website-anim-up" id="website-client-class-entrust-add" lay-title="委托课题新增">
    <div class="layui-row layui-col-space8 website-container">
        <div class="layui-col-md10 layui-col-sm10 layui-col-xs10">
            <form class="layui-form" lay-filter="class-entrust-add-form" id="class-entrust-add-form">
                <!--         基本情况       -->
                <div class="layui-card" id="client-class-entrust-info">
                    <div class="layui-card-header">基本情况</div>
                    <div class="layui-card-body layui-form-item">
                        <div class="layui-row">
                            <div class="layui-form-item website-hide">
                                <label class="layui-form-label">leaderid：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="leader.applicantId"
                                           data-th-value="${leader.applicantId}">
                                </div>
                            </div>
                            <!-- 基本信息-->
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">课题名称</label>
                                <div class="layui-input-block">
                                    <input type="text" name="name" lay-verify="required" autocomplete="off"
                                           class="layui-input" maxlength="50">
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">申报年份</label>
                                <div class="layui-input-block">
                                    <input type="text" id="applyYear" lay-verify="required" name="year"
                                           autocomplete="off" maxlength="50"
                                           class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">选题名称</label>
                                <div class="layui-input-block">
                                    <select name="topicId" lay-verify="required" id="topicId" lay-filter="topicId">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${topics}"
                                                th:value="${item.topicId}" th:text="${item.topicName}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">研究类型</label>
                                <div class="layui-input-block">
                                    <select name="researchTypeCode" lay-verify="required" lay-filter="researchTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${research}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">申报级别</label>
                                <div class="layui-input-block">
                                    <select name="levelTypeCode" lay-verify="required"
                                            lay-filter="tutorTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${wtktlb}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require"> 学科分类</label>
                                <div class="layui-input-block">
                                    <select name="subjectTypeCode" lay-verify="required" lay-filter="subjectTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${subjectTypeCode}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6  ">
                                <label class="layui-form-label website-form-item-require">课题组织单位</label>
                                <div class="layui-input-block">
                                    <input type="text" name="declareEntrust.topicUnitName" autocomplete="off"
                                           lay-verify="required" maxlength="50"
                                           class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">拟结项时间</label>
                                <div class="layui-input-block">
                                    <input type="text" id="declareEntrustEstimateTime" lay-verify="required"
                                           name="declareEntrust.estimateTime" autocomplete="off"
                                           class="layui-input">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!--         牵头人信息       -->
                <div class="layui-card" id="client-class-entrust-linker">
                    <div class="layui-card-header">牵头人信息</div>
                    <div class="layui-card-body layui-form-item">
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label ">牵头人姓名</label>
                                <div class="layui-input-block">
                                    <input type="text" name="initiator.name" autocomplete="off" class="layui-input"
                                           maxlength="50">
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label">性别</label>
                                <div class="layui-input-block">
                                    <select name="initiator.sexTypeCode" lay-filter="sexTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${sex}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label ">证件类型</label>
                                <div class="layui-input-block">
                                    <select id="initiator-identityTypeCode" name="initiator.identityTypeCode"
                                            lay-filter="initiator-identityTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${identityTypeCode}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label ">证件号码</label>
                                <div class="layui-input-block">
                                    <input type="text" name="initiator.identity" autocomplete="off" class="layui-input"
                                           id="initiator-identity" maxlength="50">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row  ">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6">
                                <label class="layui-form-label ">出生日期</label>
                                <div class="layui-input-block">
                                    <input type="text" id="initiator-birthday"
                                           name="initiator.birthday"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label">民族</label>
                                <div class="layui-input-block">
                                    <select name="initiator.nationTypeCode"
                                            lay-filter="nationTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${nation}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label ">行政职务</label>
                                <div class="layui-input-block">
                                    <select name="initiator.positionTypeCode" lay-filter="positionTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${positionTypeCode}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label">政治面貌</label>
                                <div class="layui-input-block">
                                    <select name="initiator.politicalTypeCode" lay-filter="politicalTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${political}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row  ">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label ">联系电话</label>
                                <div class="layui-input-block">
                                    <input type="text" name="initiator.telephone" lay-verify="tellphone"
                                           autocomplete="off"
                                           class="layui-input" maxlength="50">
                                </div>
                            </div>

                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label ">手机号</label>
                                <div class="layui-input-block">
                                    <input type="text" name="initiator.mobile" lay-verify="phone"
                                           autocomplete="off"
                                           class="layui-input" maxlength="50">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label ">工作单位</label>
                                <div class="layui-input-block">
                                    <input type="text" name="initiator.companyAddress" autocomplete="off"
                                           maxlength="50" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label ">邮政编码</label>
                                <div class="layui-input-block">
                                    <input type="text" name="initiator.postCode" lay-verify="number" maxlength="50"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row  ">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label ">通讯地址</label>
                                <div class="layui-input-block">
                                    <input type="text" name="initiator.address" maxlength="50"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!--         主持人信息       -->
                <div class="layui-card" id="client-class-entrust-applicant-info">
                    <div class="layui-card-header">主持人信息</div>
                    <div class="layui-card-body layui-form-item">
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">主持人姓名</label>
                                <div class="layui-input-block">
                                    <input type="text" name="leader.name" autocomplete="off" class="layui-input"
                                           lay-verify="required" maxlength="50">
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label">性别</label>
                                <div class="layui-input-block">
                                    <select name="leader.sexTypeCode" lay-filter="sexTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${sex}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>

                        </div>
                        <div class="layui-row ">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">证件类型</label>
                                <div class="layui-input-block">
                                    <select id="identityTypeCode" name="leader.identityTypeCode"
                                            lay-filter="identityTypeCode"
                                            lay-verify="required">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${identityTypeCode}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">证件号码</label>
                                <div class="layui-input-block">
                                    <input id="identity" type="text" name="leader.identity" autocomplete="off"
                                           class="layui-input"
                                           lay-verify="required" maxlength="50">
                                </div>
                            </div>

                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6">
                                <label class="layui-form-label website-form-item-require">出生日期</label>
                                <div class="layui-input-block">
                                    <input type="text" lay-verify="required" id="birthday" name="leader.birthday"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label">民族</label>
                                <div class="layui-input-block">
                                    <select name="leader.nationTypeCode"
                                            lay-filter="nationTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${nation}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">行政职务</label>
                                <div class="layui-input-block">
                                    <select name="leader.positionTypeCode" lay-verify="required"
                                            lay-filter="positionTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${positionTypeCode}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">职称级别</label>
                                <div class="layui-input-block">
                                    <select name="leader.titleTypeCode" lay-verify="required"
                                            lay-filter="titleTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${titleTypeCode}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">职称</label>
                                <div class="layui-input-block">
                                    <input type="text" name="leader.professionCode" maxlength="50" lay-verify="required"
                                           autocomplete="off"
                                           class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">工作单位</label>
                                <div class="layui-input-block">
                                    <input type="text" name="leader.company" maxlength="50" lay-verify="required"
                                           autocomplete="off"
                                           class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row  ">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label">政治面貌</label>
                                <div class="layui-input-block">
                                    <select name="leader.politicalTypeCode" lay-filter="politicalTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${political}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label">外语语种</label>
                                <div class="layui-input-block">
                                    <select name="leader.language" lay-filter="language">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${language}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row  ">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">最终学位</label>
                                <div class="layui-input-block">
                                    <select name="leader.degreeTypeCode" lay-verify="required"
                                            lay-filter="degreeTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${degree}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>

                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label ">担任导师</label>
                                <div class="layui-input-block">
                                    <select name="leader.tutorTypeCode" lay-filter="tutorTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${tutor}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row  ">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">通讯地址</label>
                                <div class="layui-input-block">
                                    <input type="text" name="leader.address" maxlength="50" lay-verify="required"
                                           autocomplete="off"
                                           class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row  ">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label ">邮政编码</label>
                                <div class="layui-input-block">
                                    <input type="text" name="leader.postCode" maxlength="50" lay-verify="number"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>

                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">电子邮箱</label>
                                <div class="layui-input-block">
                                    <input type="text" name="leader.email" maxlength="50" lay-verify="required|email"
                                           autocomplete="off"
                                           class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row  ">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label ">联系电话</label>
                                <div class="layui-input-block">
                                    <input type="text" name="leader.telephone" lay-verify="telephone" maxlength="50"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>

                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">手机号</label>
                                <div class="layui-input-block">
                                    <input type="text" name="leader.mobile" lay-verify="required|phone"
                                           autocomplete="off"
                                           class="layui-input" maxlength="50">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs5 layui-col-sm5 layui-col-md12">
                                <label class="layui-form-label website-form-item-require">个人从事与课题相关领 域科研工作 的主要履历</label>
                                <div class="layui-input-block">
                                <textarea class="layui-textarea" name="leader.field" lay-verify="required"
                                          placeholder="请输入内容，限制 500 字" maxlength="500"
                                          autocomplete="off"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!--         课题组人员       -->
                <div class="layui-card" id="client-class-entrust-member">
                    <div class="layui-card-header">课题组人员</div>
                    <div class="layui-card-body website-table-full">
                        <div class="layui-row">
                            <div class="layui-col-md-offset11 layui-col-md1">
                                <div class="layui-btn layui-btn-sm layui-btn-primary table-action action-add-member">
                                    新增课题组成员
                                </div>
                            </div>
                        </div>
                        <table id="classApplyMemberTable" lay-filter="classApplyMemberTable"
                               lay-data="{id: 'classApplyMemberTable'}"></table>
                    </div>
                </div>
                <!--         主持人曾经主持省部级以上社科研究项目及完成情况       -->
                <div class="layui-card" id="client-class-entrust-project-info">
                    <div class="layui-card-header">主持人曾经主持省部级以上社科研究项目及完成情况</div>
                    <div class="layui-card-body website-table-full">
                        <div class="layui-row">
                            <div class="layui-col-md-offset11 layui-col-md1">
                                <div class="layui-btn layui-btn-sm layui-btn-primary table-action action-add-project-info">
                                    新增信息
                                </div>
                            </div>
                        </div>
                        <table lay-filter="classApplyProjectInfoTable" id="classApplyProjectInfoTable"
                               lay-data="{id: 'classApplyProjectInfoTable'}"></table>
                    </div>
                </div>
                <!--         研究基础和研究条件       -->
                <div class="layui-card">
                    <div class="layui-card-header">研究基础和研究条件</div>
                    <div class="layui-card-body layui-form-item">
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs5 layui-col-sm5 layui-col-md12">
                                <span class="website-form-item-require">主持人近5年发表、出版的相关研究成果（注明刊物的年、期或出版社、出版日期）</span>
                                <textarea class="layui-textarea" name="leaderWorks5" placeholder="请输入内容、限制 500 字"
                                          lay-verify="required" maxlength="500"
                                          autocomplete="off"></textarea>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs5 layui-col-sm5 layui-col-md12">
                                <span class="website-form-item-require">课题组成员近3年发表、出版的与本课题有关的主要研究成果（注明刊物的年、期或出版社、出版日期）</span>
                                <textarea class="layui-textarea" placeholder="请输入内容" name="memberWorks3"
                                          lay-verify="required" maxlength="500"
                                          autocomplete="off"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 课题论证-->
                <div class="layui-card" id="client-class-entrust-argument">
                    <div class="layui-card-header">课题论证</div>
                    <div class="layui-card-body layui-form-item">
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs5 layui-col-sm5 layui-col-md12">
                                <span class="website-form-item-require">一、对选题的实践价值和理论价值的理解（限500字）</span>
                                <textarea class="layui-textarea" name="declareEntrust.proofUnderstand"
                                          lay-verify="required"
                                          autocomplete="off" maxlength="500"></textarea>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs5 layui-col-sm5 layui-col-md12">
                                <span class="website-form-item-require">二、主要研究内容、研究思路、研究的重点、难点及可能的创新之处（限1500字）</span>
                                <textarea class="layui-textarea" name="declareEntrust.proofInnovate"
                                          lay-verify="required"
                                          autocomplete="off" maxlength="1500"></textarea>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs5 layui-col-sm5 layui-col-md12">
                                <span class="website-form-item-require">三、研究方法和课题组合作机制（限800字）</span>
                                <textarea class="layui-textarea" name="declareEntrust.proofMechanism"
                                          lay-verify="required"
                                          autocomplete="off" maxlength="800"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 研究内容-->
                <div class="layui-card  " id="client-class-Solicit">
                    <div class="layui-card-header">研究计划</div>
                    <div class="layui-card-body layui-form-item">
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs5 layui-col-sm5 layui-col-md12">
                                <span class="website-form-item-require">（本课题研究周期为1年。请制定研究进度计划、推进的方式、每一阶段的成果目标，限1000字）</span>
                                <textarea class="layui-textarea" name="declareEntrust.researchPlan" placeholder="请输入内容"
                                          lay-verify="required"
                                          autocomplete="off" maxlength="1000"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-card" id="client-class-draft-achievement">
                    <div class="layui-card-header">拟完成的研究成果</div>
                    <div class="layui-card-body website-table-full">
                        <div class="layui-row">
                            <div class="layui-col-md-offset11 layui-col-md1">
                                <div class="layui-btn layui-btn-sm layui-btn-primary table-action action-add-draft-achievement">
                                    新增信息
                                </div>
                            </div>
                        </div>
                        <table lay-filter="classDraftAchievementTable" id="classDraftAchievementTable"
                               lay-data="{id: 'classDraftAchievementTable'}"></table>
                    </div>
                </div>
                <div class="layui-card-footer">
                    <button class="layui-btn" id="submit" lay-submit="" lay-filter="class-entrust-add-form-submit">保存
                    </button>
                    <button class="layui-btn" id="reset">返回</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--成员表-->
<!--成员表操作栏-->
<script type="text/html" id="member-option">
    <a lay-event="edit" class="website-blue">修改</a>
    <a lay-event="del" class="website-red">删除</a>
</script>
<!--主持人表-->
<!--主持人表操作栏-->
<script type="text/html" id="project-option">
    <a lay-event="edit" class="website-blue">修改</a>
    <a lay-event="del" class="website-red">删除</a>
</script>
<script type="text/html" id="result-option">
    <a lay-event="edit" class="website-blue">修改</a>
    <a lay-event="del" class="website-red">删除</a>
</script>
<script type="text/html" id="identity-type">
    {{#
    let dict=layui.dict.getByCode(d.identityTypeCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<!--字典-->
<script type="text/html" id="sex-type">
    {{#
    let dict=layui.dict.getByCode(d.sexTypeCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<script type="text/html" id="position-type">
    {{#
    let dict=layui.dict.getByCode(d.positionTypeCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<script type="text/html" id="title-type">
    {{#
    let dict=layui.dict.getByCode(d.titleTypeCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<script type="text/html" id="degree-type">
    {{#
    let dict=layui.dict.getByCode(d.degreeTypeCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<script type="text/html" id="achievement-form-name-type">
    {{#
    let dictList=layui.dict.getByCodes(d.performance ? d.performance.split(','): '');
    }}
    <span>
    {{# layui.each(dictList,function(index,item) { }}
    {{ item.name }}&nbsp;
    {{#  }); }}
    </span>
</script>
<script type="text/html" id="finish-type">
    {{#  if(d.isFinish === 'true' ){ }}
    <span>是</span>
    {{#  }else{ }}
    <span>否</span>
    {{#  } }}
</script>

<script data-th-inline="javascript" type="text/javascript">
    layui.use(['jquery', 'laydate', 'form', 'table', 'website', 'upload', 'dict', 'formSelects', 'validate', 'clientModules'], function () {
        let $ = layui.jquery,
            laydate = layui.laydate,
            website = layui.website,
            form = layui.form,
            formSelects = layui.formSelects,
            table = layui.table,
            upload = layui.upload,
            client = layui.clientModules,
            validate = layui.validate,

            $view = $('#website-client-class-entrust-add'),
            $form = $('#class-entrust-add-form'),
            $achievementView = $('#client-class-draft-achievement'),
            $submit = $('#submit'),
            $reset = $('#reset'),
            $topicId = $('#topicId'),
            $projectView = $('#client-class-entrust-project-info'),
            $memberView = $('#client-class-entrust-member'),
            $addProject = $projectView.find('.action-add-project-info'),
            $addMember = $memberView.find('.action-add-member'),
            $addachievement = $achievementView.find('.action-add-draft-achievement'),

            leader = [[${leader}]],
            classType = [[${classType}]],
            achievementForm = [[${achievementForm}]],


            memberTableIns,
            projectInfoTableIns,
            draftAchievementTableIns;

        document.getElementById('website-client-class-entrust-add').scrollIntoView();
        initMemberTable();
        initProjectInfoTable();
        initDraftAchievement();


        // 重新渲染 form否则不会显示下拉框
        form.render();
        formSelects.render();
        form.verify(validate);

        //初始化年份的搜索框
        laydate.render({
            elem: '#applyYear', //指定元素
            type: 'year',
            trigger: 'click',
            done: function (value, date, endDate) {
                date.topicClassifyCode = classType
                website.get(ctx + 'topics/declare', date, function (data) {
                    // 清空下拉框
                    $topicId.empty()
                    let result = data.data,
                        html = '<option value="">请选择</option>\n';
                    $.each(result, function (i, item) {
                        html += '<option value="' + item.topicId + '">' + item.topicName + '</option>\n'
                    })
                    $topicId.append(html);
                    //从新刷新了一下下拉框
                    form.render('select');
                });
            }
        });
        laydate.render({
            elem: '#declareEntrustEstimateTime', //指定元素
            trigger: 'click',
        });


        laydate.render({
            //
            elem: '#birthday', //指定元素
            type: 'date',
            max: 0
        })
        laydate.render({
            //
            elem: '#initiator-birthday', //指定元素
            type: 'date',
            max: 0
        })

        function initMemberTable() {
            memberTableIns = website.table.init({
                elem: $memberView.find('table'),
                id: 'classApplyMemberTable',
                cols: [
                    [
                        {type: 'numbers', title: '序号'},
                        {field: 'name', title: '姓名'},
                        {title: '性别', templet: '#sex-type'},
                        {field: 'birthday', title: '出生年月'},
                        {title: '职务', templet: '#position-type'},
                        {title: '职称级别', templet: '#title-type'},
                        {title: '职称', field: 'professionCode'},
                        {title: '最终学位', templet: '#degree-type'},
                        {field: 'field', title: '研究领域'},
                        {templet: '#identity-type', title: '证件类型'},
                        {field: 'identity', title: '证件号'},
                        {field: 'companyAddress', title: '工作单位'},
                        {field: 'mobile', title: '联系电话'},
                        {field: 'email', title: '电子邮箱'},
                        {title: '操作', toolbar: '#member-option', minWidth: 140}
                    ]
                ],
                data: [],
                page: false,
                limit: Number.MAX_VALUE
            });
        }

        table.on('tool(classApplyMemberTable)', function (obj) {
            let data = obj.data,
                layEvent = obj.event;
            if (layEvent === 'del') {
                website.modal.confirm('删除成员', '确定删除该成员？', function () {
                    deleteMembers(obj);
                });
            }
            if (layEvent === 'edit') {
                // 修改
                client.openMember(obj, memberTableIns)
            }
        });

        // 选题征集新增按钮页面跳转
        $addMember.on('click', function () {
            client.openMember({}, memberTableIns)
        })


        function initProjectInfoTable() {
            projectInfoTableIns = website.table.init({
                elem: $projectView.find('table'),
                id: 'classApplyProjectInfoTable',
                cols: [
                    [
                        {type: 'numbers', title: '序号'},
                        {field: 'projectSource', title: '项目来源', minWidth: 100},
                        {field: 'type', title: '类别'},
                        {field: 'topicName', title: '课题名称', minWidth: 200},
                        {field: 'projectTime', title: '立项时间', minWidth: 165},
                        {templet: '#finish-type', title: '是否结项'},
                        {title: '操作', toolbar: '#project-option', minWidth: 140}
                    ]
                ],
                data: [],
                page: false,
                limit: Number.MAX_VALUE
            });
        }

        table.on('tool(classApplyProjectInfoTable)', function (obj) {
            let data = obj.data,
                layEvent = obj.event;
            if (layEvent === 'del') {
                website.modal.confirm('删除项目', '确定删除该项目？', function () {
                    deleteProjectInfos(obj);
                });
            }
            if (layEvent === 'edit') {  // 修改
                client.openProject(obj, projectInfoTableIns)
            }
        });


        // 课题申报新增按钮页面跳转
        $addProject.on('click', function () {
            client.openProject({}, projectInfoTableIns)
        })


        $addachievement.on('click', function () {
            client.addAchievement({}, draftAchievementTableIns, achievementFormBaseArray())
        })

        function initDraftAchievement() {
            draftAchievementTableIns = website.table.init({
                elem: $achievementView.find('table'),
                id: 'classDraftAchievementTable',
                cols: [
                    [
                        {type: 'numbers', title: '序号', width: '8%'},
                        {templet: '#achievement-form-name-type', title: '成果形式', width: '32%'},
                        {field: 'number', title: '成果字数（万字）', width: '13%'},
                        {field: 'completeTime', title: '完成时间', width: '10%'},
                        {title: '操作', toolbar: '#result-option', minWidth: 140}
                    ]
                ],
                data: [],
                page: false,
                limit: Number.MAX_VALUE
            });
        }

        table.on('tool(classDraftAchievementTable)', function (obj) {
            let data = obj.data,
                layEvent = obj.event;
            if (layEvent === 'del') {
                website.modal.confirm('删除项目', '确定删除该项目？', function () {
                    deleteAchievement(obj);
                });
            }
            if (layEvent === 'edit') {
                // 修改
                client.addAchievement(obj, draftAchievementTableIns, achievementFormBaseArray())
            }
        });

        function deleteAchievement(obj) {
            let data = obj.data
            // 从缓存中删除
            let cacheData = table.cache["classDraftAchievementTable"];
            cacheData.splice(obj.tr.data('index'), 1)//根据索引删除当前行
            draftAchievementTableIns.reload({
                data: cacheData
            });
        }


        //    保存表单
        form.on('submit(class-entrust-add-form-submit)', function () {
            // 1. 当前页表单
            let temp = $form.serializeArray(),
                formData = website.serializeObject(temp);
            // 2. 成员表序列化
            formData.memberInfos = table.cache["classApplyMemberTable"]
            // 3. 项目表序列化
            formData.leaderProjects = table.cache["classApplyProjectInfoTable"];
            formData.draftAchievements = table.cache["classDraftAchievementTable"];
            let params = JSON.stringify(formData)
            website.ajaxPost(ctx + 'entrustAdd', params, function () {
                //  关闭当前页面
                $('#website-home').find('#query-entrust').click();
                let currentUrl = window.location.hash.replace('#', '');
                website.view.tab.del(currentUrl);
                window.location.reload();
            });
            return false;
        });

        function deleteMembers(obj) {
            let data = obj.data
            // 从缓存中删除
            let cacheData = table.cache["classApplyMemberTable"];
            cacheData.splice(obj.tr.data('index'), 1)//根据索引删除当前行
            memberTableIns.reload({
                data: cacheData
            });

        }

        function deleteProjectInfos(obj) {
            let data = obj.data
            // 从缓存中删除
            let cacheData = table.cache["classApplyProjectInfoTable"];
            cacheData.splice(obj.tr.data('index'), 1)//根据索引删除当前行
            projectInfoTableIns.reload({
                data: cacheData
            });

        }

        initExpertValue()

        function initExpertValue() {
            form.val("class-entrust-add-form", {
                "leader.name": leader.name,
                "leader.positionTypeCode": leader.positionTypeCode,
                "leader.professionCode": leader.professionCode,
                "leader.titleTypeCode": leader.titleTypeCode,
                "leader.sexTypeCode": leader.sexTypeCode,
                "leader.nationTypeCode": leader.nationTypeCode,
                "leader.identity": leader.identity,
                "leader.politicalTypeCode": leader.politicalTypeCode,
                "leader.degreeTypeCode": leader.degreeTypeCode,
                "leader.tutorTypeCode": leader.tutorTypeCode,
                "leader.language": leader.language,
                "leader.email": leader.email,
                "leader.company": leader.company,
                "leader.address": leader.address,
                "leader.postCode": leader.postCode,
                "leader.telephone": leader.telephone,
                "leader.field": leader.field,
                "leader.birthday": leader.birthday,
                "leader.identityTypeCode": leader.identityTypeCode,
                "leader.mobile": leader.mobile
            });
        }


        function achievementFormBaseArray() {
            let baseData = []
            $.each(achievementForm, function (i, item) {
                let temp = {name: item.name, value: item.code}
                baseData.push(temp)
            })
            return baseData
        }

        $reset.on('click', function () {
            //  关闭当前页面
            $('#website-home').find('#query-entrust').click();
            let currentUrl = window.location.hash.replace('#', '');
            website.view.tab.del(currentUrl);
            window.location.reload();
        })


        form.on('select(identityTypeCode)', function (data) {
            if ("zjlx_sfz" === data.value) {
                // lay-verify="required|identity"
                $('#leader-identity')[0].setAttribute('lay-verify', "required|identity")
            } else if (data.value) {
                $('#leader-identity')[0].setAttribute('lay-verify', "required")
            }
        });

        form.on('select(initiator-identityTypeCode)', function (data) {
            if ("zjlx_sfz" === data.value) {
                // lay-verify="required|identity"
                $('#initiator-identity')[0].setAttribute('lay-verify', "identityNumber")
            } else {
                $('#initiator-identity')[0].removeAttribute('lay-verify')
            }
        });

    });
</script>